<?php

/**
 * Description of Catalog
 *
 * @author Kam
 */
class Application_Model_DAO_StaticPage extends My_DAO_Abstract {

    const DB_STATIC_PAGE = 'StaticPage';    

    /**
     * 
     * @return Zend_Db_Table_Select
     */
    public function getEntries() {
        $select = $this->getDbTable()->select()
                ->from(array('sp' => 'static_page'))
                ->order(array('sp.static_page_id ASC'))
        ;
        return $select;
    }


    public function update($staticPageId, array $data) {
        return $this->getDbTable()->update($data, $staticPageId);
    }

    public function addNew($formData) {
        $staticPageRecord = array();
        $this->setSafety($staticPageRecord, $formData, 'title');
        $this->setSafety($staticPageRecord, $formData, 'content');

        $staticPageId = $this->getDbTable()->insert($staticPageRecord);

        $staticPageRecord = $this->getDbTable()->get($staticPageId);
        return $staticPageRecord;
    }
    
    public function getStaticPageByColumn($id, $column = 'static_page_id') {
        return $this->getDbTable(self::DB_STATIC_PAGE)->getByColumn($id, $column);
    }

    protected function getDbTableNameMap() {
        return array(
            self::DB_STATIC_PAGE => 'Application_Model_DbTable_StaticPage',
        );
    }

    protected function getDefaultDbTableName() {
        return self::DB_STATIC_PAGE;
    }

}
